{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# On-Site Question 3 - SOLUTION\n",
    "\n",
    "## Question\n",
    "\n",
    "**Given a string, write a function that uses recursion to reverse it. **\n",
    "\n",
    "## Requirements\n",
    "\n",
    "** You MUST use pen and paper or a whiteboard to answer this, no coding allowed! **"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "____"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# SOLUTION\n",
    "\n",
    "Hopefully you remember this problem, you've already seen it! The solution is:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def reverse(s):\n",
    "    \n",
    "    # Base Case\n",
    "    if len(s) <= 1:\n",
    "        return s\n",
    "\n",
    "    # Recursion\n",
    "    return reverse(s[1:]) + s[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "___\n",
    "## Notes\n",
    "\n",
    "Remember when recursion questions arise, think about the base case and the recursive case. Review the recusion section of the course for review for this problem."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Good Job!"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
